package com.villaday.idf.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.model.RecommendEntity;
import com.villaday.idf.model.RefreshtokenEntity;
import com.villaday.idf.model.memberAchievements;
import com.villaday.idf.util.PhoneUtil;
import com.villaday.idf.util.SharedPreferencesUtil;

/**
 * Vip客户列表适配器，单独使用
 */

public class PerformanceListAdapter extends AbsRecyclerViewAdapter<memberAchievements.BodyBean.ListBean> {
    private OnAdapterCallbackListener onAdapterCallbackListener;
    private View.OnClickListener onClickListener;
    private final String roleType;
    private Context mContext;

    public PerformanceListAdapter(Context context, OnAdapterCallbackListener onAdapterCallbackListener) {
        super(context, R.layout.recyclerview_performance_list, R.layout.item_page_loading,
                R.layout.item_page_bottom);
        this.onAdapterCallbackListener = onAdapterCallbackListener;
        this.mContext = context;
        RefreshtokenEntity.BodyBean roleInfo =
                SharedPreferencesUtil.getRoleInfo(context);
        roleType = roleInfo.getMember().getType();

    }

    @Override
    public int getItemType(memberAchievements.BodyBean.ListBean d) {
        return d.getMyType();
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, memberAchievements.BodyBean.ListBean d, int position) {
        switch (d.getMyType()) {

            case 0: {

                TextView seriousNum = (TextView) holder.getView(R.id.tv_serial_num);
                switch (position) {
                    case 0: {
                        seriousNum.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_one));
                        holder.bindTextView(R.id.tv_serial_num,"");
                        break;
                    }
                    case 1: {
                        seriousNum.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_two));
                        holder.bindTextView(R.id.tv_serial_num,"");
                        break;
                    }
                    case 2: {
                        seriousNum.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_three));
                        holder.bindTextView(R.id.tv_serial_num,"");
                        break;
                    }
                    default: {
                        holder.bindTextView(R.id.tv_serial_num, (position + 1) + "");
                        seriousNum.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_four));
                    }
                    break;
                }

                holder.bindSimpleDraweeView(R.id.sdv_userHead, d.getHeaderUrl())
                        .bindTextView(R.id.tv_title, d.getNickName())
                        .bindTextView(R.id.tv_order_num, d.getProfit().getOrders() + "单")
                        .bindTextView(R.id.tv_order_price, PhoneUtil.handleDecimal2((Integer.parseInt(d.getProfit().getAmounts()) / 100.0) + "") + "元");

            }
            break;

            case 1: {
                onAdapterCallbackListener.onCallback();
            }
            break;


        }
    }
}
